#/bin/bash

function usage() {
  echo "Usage: ${cmd} [-h | -f <cpp_file>] <item_to_add> <item_to_add> ..."
  echo -e "把所有<cpp_file>中的符号<item_to_add>替换为this-><item_to_add>"
  echo -e "\t-f: 指定待替换的文件"
  echo -e "\t-h: 输出此信息"
  exit 1
}

cpp_file=""
while getopts "hf:" arg
do
  case "${arg}" in 
    f)
      cpp_file=${OPTARG}
      shift
      shift
      ;;
    *)
      usage
      ;;
  esac
done

for key in "${@}"
do
  echo sed -i "s/\<${key}\>/this->&/g" "${cpp_file}"
  sed -i "s/\<${key}\>/this->&/g" "${cpp_file}"
done
